<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TbAppAreas> list = (List<TbAppAreas>)request.getAttribute("list");
	AreaMapForm form = (AreaMapForm)request.getAttribute("command");
	String areaname = StringUtils.isNotBlank(form.getAreaname())?form.getAreaname():"";
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String siteid = user.getSiteId();
	
%>

<div class="userListWrap">
    <form id="userListForm">
    	<div class="form-item">
    		<label for="prov">省份:</label>
    		<select class="easyui-combobox"  name="prov" id="prov" style="width:100px;"></select>
        </div>
        <div class="form-item">
    		<label for="city">城市:</label>
    		<select class="easyui-combobox"  name="city" id="city" style="width:100px;"></select>
        </div>
        <div class="form-item">
    		<label for="userId">围栏:</label>
    		<input class="easyui-validatebox" type="text" name="areaname" data-options="" value="<%=areaname%>"/>
        </div> 	
        <div class="form-item form-item">
    		<a href="javascript:XF.Area.listAreaMapSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>
        
    </form>

    <table id="areaMapListTable" class="easyui-datagrid"  title="" >
        <thead>
    		<tr>
    		    <th data-options="field:'areaname',width:80">区域围栏</th>				
				<th data-options="field:'sitename',width:80">站点名称</th>
				<th data-options="field:'siteid',width:60">站点ID</th>				
    			<th data-options="field:'province',width:90">省份</th>
    			<th data-options="field:'city',width:95">城市</th>
    			<th data-options="field:'enterdate',width:130" >添加时间</th>
    			<th data-options="field:'checkdate',width:130" >更新时间</th>
    			<th data-options="field:'pro',width:120">操作</th>
    		</tr>
        </thead>
        <tbody>
        	<%
        		if(!CollectionUtils.isEmpty(list)){
        			for(TbAppAreas area:list){
        				%>
       					 <tr s="<%=area.getAreaid() %>">
       					 	<td><i s="<%=area.getAreaid() %>"></i><%=(null!=area.getAreaname())?area.getAreaname()+"":"" %></td>
       					 	<td><%=(null!=area.getSitename())?area.getSitename()+"":"" %></td>
       					 	<td><%=(null!=area.getSiteid())?area.getSiteid()+"":"" %></td>
       					 	<td><%=(null!=area.getProvince())?area.getProvince()+"":"" %></td>
       					 	<td><%=(null!=area.getCity())?area.getCity()+"":"" %></td>
       					 	<td><%=null!=area.getEnterdate()?DateFormatUtils.format(area.getEnterdate().getTime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
       					 	<td><%=null!=area.getCheckdate()?DateFormatUtils.format(area.getCheckdate().getTime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
				    			<td>
										<a class="inLink" href="javascript:XF.Area.editMapCore('<%=area.getAreaid()%>')"><span>编辑围栏地图</span></a>
										<a class="inLink" href="javascript:XF.Area.doDelMap('<%=area.getAreaid()%>')"><span>删除</span></a>
				    			</td>
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="areaMap_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>
</div>
<script>
	$('#areaMapListTable').datagrid();
	$(document).ready(XF.Area.bigAutocomp(""))
	//XF.Notice.initList();
	$('#prov').combobox({
		url:global.contextPath + '/destin/getProv',
		valueField:'provid',
		textField:'val',
		panelHeight:300,
		onSelect:function(record){
			$('#city').combobox('clear'); //清除原来的数据  
			$('#area').combobox('clear');
	        var url = global.contextPath + '/destin/getCity?prov=' + record.val; 
	        $('#city').combobox('reload', url);//联动下拉列表重载 
	       },
       onHidePanel:function(){
			var _options = $(this).combobox('options');  
		    var _data = $(this).combobox('getData');/* 下拉框所有选项 */  
		    var _value = $(this).combobox('getValue');/* 用户输入的值 */  
		    var _b = false;/* 标识是否在下拉列表中找到了用户输入的字符 */  
		    for (var i = 0; i < _data.length; i++) {  
		        if (_data[i][_options.valueField] == _value) {  
		            _b=true;  
		            break;  
		        }  
		    }  
		    if(!_b){  
		        $(this).combobox('setValue', '');  
		    } 
          }
	});
	$('#city').combobox({
		valueField:'cityid',
		textField:'val',
		panelHeight: 300,
		onHidePanel:function(){
			var _options = $(this).combobox('options');  
		    var _data = $(this).combobox('getData');/* 下拉框所有选项 */  
		    var _value = $(this).combobox('getValue');/* 用户输入的值 */  
		    var _b = false;/* 标识是否在下拉列表中找到了用户输入的字符 */  
		    for (var i = 0; i < _data.length; i++) {  
		        if (_data[i][_options.valueField] == _value) {  
		            _b=true;  
		            break;  
		        }  
		    }  
		    if(!_b){  
		        $(this).combobox('setValue', '');  
		    } 
          }
	});
</script>





























